package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdChannel;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;
    /**
     * 获取频道列表
     * @return
     */
    @GetMapping("channels")
    public ResponseResult channels(){
        return wmChannelService.channels();

    }

    //删除频道
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id){
        return wmChannelService.deleteChannel(id);
    }

    //模糊分页查询
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto){
        return wmChannelService.channelsList(dto);
    }

    //新增频道
    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel dto){
        return wmChannelService.save(dto);
    }

    //更新数据
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return wmChannelService.update(adChannel);
    }
}
